<template>

    <div class="city">
        <city-header />
        <city-search :citysList="citysList" />
        <city-list :citysList="citysList"
                   :hotCitysList="hotCitysList"
                   :letter="letter"
        />
        <city-alphabet
            :citysList="citysList"
            @change="handleLetterChange"
        />
    </div>

</template>

<script>
import CityHeader from './components/Header.vue'
import CitySearch from './components/Search'
import CityList from './components/List'
import CityAlphabet from './components/Alphabet'
import axios from '@/axios'
export default {
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  data () {
    return {
      citysList: {},
      hotCitysList: [],
      letter: ''
    }
  },
  methods: {
    getCityInfo () {
      axios.get('city.json').then((res) => {
        res = res.data
        if (res.ret && res.data) {
          const data = res.data
          this.citysList = data.cities
          this.hotCitysList = data.hotCities
          // console.log(data);
        }
      })
    },
    handleLetterChange (letter) {
      this.letter = letter
    }
  },
  mounted () {
    this.getCityInfo()
  }
}
</script>
